<?php
session_start();
include 'inc/db_connect.php';
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">  
<link rel="stylesheet" href="./css/my.css"/>
<title>Wlog</title>
</head>

<body>


<?php
  include 'inc/gen_header.php';
  gen_header('<a href=".">Query</a> | <a href=task.php>Task</a> | Wlog');
?>

<?php

if(!isset($_SESSION['logged'])) {
  echo '<p>未登录</p>';
}  else {
?>
<center>
<div>
<?php

//echo "<p>hello</p>";

$get_tasks_sql = " select id from task_info where creator_user_id = ".$_SESSION["user_id"]." and is_trip_out = 1";
echo 'get_tasks_sql = '.$get_tasks_sql.'<br>';
$query_tasks = mysql_query($get_tasks_sql);
$num = mysql_num_rows($query_tasks);
$tripdays = 0;
  	// foreach($query_tasks as $query_task) {
    
   // $get_endday_sql = "select distinct end_time from work_log where task_id = ".$query_task;
   // echo 'get_endday_sql = '.$get_endday_sql.'\n';
   // $days = mysql_query($get_endday_sql);
   // tripdays += mysql_num_rows($days);
  
 // }
  while($result = mysql_fetch_array($query_tasks))
  {
  	$get_endday_sql = "select distinct end_time from work_log where task_id = ".$result["id"];
  	echo 'get_endday_sql = '.$get_endday_sql.'<br>';
  	$days = mysql_query($get_endday_sql);
        $tripdays += mysql_num_rows($days);
  }
  //1.一句sql语句实现 2.取时间时只保留到天 3.添加where可以查询时间段
 echo 'num:'.$num.'.';
echo 'tripdays:'.$tripdays.'.';



?>
</center>
</div>

<?php 
}
include 'inc/footer.php';

?>

</body>

</html>